package StudyCode.UI;

import javax.swing.*;
import java.awt.*;

/**
 * @author lixiaoyao
 * @date 2018/11/12 0012、下午 12:50
 * @description 绘制字符串
 */
public class NotHelloWorld {
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				JFrame frame = new NotHelloWorldFrame();
				frame.setTitle("NotHelloWorld");
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setVisible(true);
			}
		});
	}
}

class NotHelloWorldFrame extends JFrame {
	public NotHelloWorldFrame() {
		add(new NotHelloWorldComponent());
		pack();
	}
}

class NotHelloWorldComponent extends JComponent {
	private static final int MESSAGE_X = 75;
	private static final int MESSAGE_Y = 100;

	private static final int DEFAULT_WIDTH = 300;
	private static final int DEFAULT_HEIGHT = 200;

	public void paintComponent(Graphics g) {
		g.drawString("Not a Hello,World program", MESSAGE_X, MESSAGE_Y);
	}

	public Dimension getPreferredSize() {
		return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	}

}